package daily;

/**
 * @Date 2022/1/15
 * @Created by Jonathan
 */
public class ClientO {
    public static void main(String[] args) {
        DefaultSingletonBeanRegistry beanRegistry = new DefaultSingletonBeanRegistry();
        Object singleton = beanRegistry.getSingleton("testName", ClientO::createObject);

        System.out.println(singleton);
    }

    static Object createObject() {
        Stu stu = new Stu();
        stu.setName("hah");
        return stu;
    }

    static class Stu {
        String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Stu{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }
}
